package viewer

import (
	"fmt"
	"net/http"

	"github.com/gin-contrib/sessions"
	"github.com/gin-gonic/gin"
	"src/myaccount.go/src/model"
)

func PingTest(c *gin.Context) {
	session := sessions.Default(c)
	user := session.Get("userkey")
	c.JSON(200, gin.H{
		"message": "成功",
		"user":    user,
	})
}

func CreateUser(c *gin.Context) {
	users, err := model.ListUsers()
	if err != nil {
		fmt.Println(err)
	}

	c.HTML(http.StatusOK, "createuser", gin.H{
		"users": users,
	})
}
